<template>
  <div class="header">
    <div class="wrap">
      <div class="b" onclick="goBack()">
        <i class="iconfont icon-tuihui b-i"></i>
      </div>
      <h1 class="t" :class="headerAnimate_get">
        <span>{{title}}</span>
      </h1>
      <transition-group name="fadeShow">
        <!--添加icon-->
        <div class="r"
             :key="1"
             v-if="headerType === 1">
          <i class="iconfont icon-tianjia b-i"></i>
        </div>
        <div class="r con"
             :key="2"
             v-if="headerType === 2"
             @click="_confirm">
          确定
        </div>
        <div class="r con"
             :key="2"
             v-if="headerType === 3"
             @click="_edit">
          编辑
        </div>
      </transition-group>
    </div>
  </div>
</template>

<script>
  import {mapGetters, mapState} from 'vuex'

  const headerConfirmFlag = "headerConfirm_";
  const headerEditFlag = "headerEdit_";

  export default {
    methods: {
      _confirm(){
        bus.$emit(headerConfirmFlag + this.showFlag);
      },
      _edit(){
        bus.$emit(headerEditFlag + this.showFlag);
      }
    },
    computed: {
      ...mapState([
        'title',
        'headerAnimate_get',
        'headerType',
      ]),
      ...mapGetters([
        'headerAnimate_get',
      ])
    }
  }

</script>

<style lang="scss">
  @import "../scss/mixin";
  .header {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 100;
    background-color: $themBlue;
    color: #fff;
    border-bottom: 1px solid #d8d8d8;
    .wrap {
      position: relative;
    }
    $height: 40px;
    @mixin _height {
      height: $height;
      line-height: $height;
      text-align: center;
    }

    .b {
      position: absolute;
      left: 0;
      top: 0;
      width: 46px;
      font-size: 22px;
      @include _height;
      &:active .b-i {
        font-size: 26px;
      }
      .b-i {
        font-size: 22px;
        font-weight: 700;
      }
    }

    .r {
      position: absolute;
      top: 0;
      right: 0;
      width: 46px;
      font-size: 22px;
      @include _height;
      &:active .b-i {
        font-size: 26px;
      }
      .b-i {
        font-size: 22px;
        font-weight: 700;
      }
    }
    .con {
      font-size: 15px;
    }

    .t {
      margin: 0 88px;
      position: relative;
      width: auto;
      font-weight: 400;
      font-size: 16px;
      @include wordHidden;
      @include _height;
    }
  }
</style>
